package com.ws.oss.controller;

import com.ws.commonutils.R;
import com.ws.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author ws
 * @create 2024-12-03 16:54
 */
@RestController
@RequestMapping("/eduoss/fileoss")
@CrossOrigin
public class FileController {

    @Autowired
    OssService ossService;

    @PostMapping("upload")
    public R uploadFile(MultipartFile file) {
        String url=ossService.uploadFlie(file);
        return R.ok().data("url",url);
    }

    @DeleteMapping("delete")
    public R deleteFile(@RequestParam("url") String url) {
        ossService.delete(url);
        return R.ok();
    }
}
